﻿//===================================================================================
// Copyright (c) Ryan Garrett.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===================================================================================
using System;
using System.Collections.Generic;

namespace Caffeine.Core
{
    /// <summary>
    /// Implementers of this type keep track of the total number of changes made to a model graph
    /// </summary>
    public interface IPropertyChangeCounter
    {
        /// <summary>
        /// Gets the number of changes that have been made to a model or model graph.
        /// </summary>
        UInt64 ChangeCount
        {
            get;
        }

        /// <summary>
        /// Increments the ChangeCount property by 1. Model properties will call this method every time their value changes
        /// if their parent model's PropertyChangeCounter property is set.
        /// </summary>
        /// <param name="property">Model property which has changed</param>
        void IncrementChangeCount(ModelPropertyBase property);

        /// <summary>
        /// Returns a list of registered observers.
        /// </summary>
        IEnumerable<Action<UInt64, ModelPropertyBase>> Observers
        {
            get;
        }

        /// <summary>
        /// Add an observer of property change notifications
        /// </summary>
        /// <param name="observerMethod">Method to call when a property is changed</param>
        void AddObserver(Action<UInt64, ModelPropertyBase> observerMethod);

        /// <summary>
        /// Remove an observer of property change notifications
        /// </summary>
        /// <param name="observerMethod">Method to call when a property is changed</param>
        void RemoveObserver(Action<UInt64, ModelPropertyBase> observerMethod);
    }
}
